<?php
namespace Service\Model;
use Think\Model\RelationModel;

class RepairTypeModel  extends RelationModel {
    public $_validate = array(
        array('name','require','字段名称必填')
    );
    
    public $_auto = array(
        array('status','1'),
    );

    public function getPName($data){
        foreach ($data as &$v) {
            $v['pid_name'] = $this->find($v['pid'])['name'];
            if(!$v['pid_name'])
                $v['pid_name'] = '无';
        }
        return $data;
    }
    public function findName($name,$pid=false){
        $where['name'] = $name;
        if($pid)
            $where['pid'] = $pid;
        $data = $this->where($where)->find();
        return $data;
    }
}
